package com.gemantic.task.util;


import java.net.InetAddress;

import org.apache.commons.lang3.StringUtils;

import com.gemantic.task.config.env.EnvConfig;

/**
 * @author xiedi
 * @date 2022/09/16
 **/
public class EnvUtil {
    public static String getComputerName() {
        String computerName;
        try {
            computerName = InetAddress.getLocalHost().getHostName();
            if (!StringUtils.isEmpty(computerName)) {

                computerName = computerName.toLowerCase().trim();
            }
        } catch (Exception e) {
            computerName = String.format("%s_%s", "", "");
        }

        return computerName;
    }

    public static EnvConfig getEnvConfig(){
        return (EnvConfig) SpringUtils.getBean(EnvConfig.class);
    }

    public static  String getProfile() {
        return getEnvConfig().getProfile();
    }
}
